/*
 *  Arrow
 *
 *  Created by David Giovannini on 1/5/07.
 *  Copyright 2007 Software by Jove. All rights reserved.
 *
 */
 
#ifndef SBJ_Container_Node_h
#define SBJ_Container_Node_h

namespace SBJ
{

template < typename Type >
class NodeQueue;

/*
Class: Node

This simple class provides the linked list node members required
for an NodeQueue. It is intentionally tightly coupled to the
NodeQueue class.

This is a polymorphic class. Inherit from it to allow insertion
into a NodeQueue.
*/

template < typename Type >
class Node
{
public:
	friend class NodeQueue< Type >;

	inline Node( void )
	: m_next( 0 )
	, m_prev( 0 )
	, m_queue( 0 )
	, m_independent( false ) {}
	
	virtual ~Node( void ) {}
	
	inline bool isQueued( void ) const { return ( m_queue != 0 ); }

	inline Node* next( void ) { return m_next; }
		
	inline Node* prev( void ) { return m_prev; }

	inline const Node* next( void ) const { return m_next; }
		
	inline const Node* prev( void ) const { return m_prev; }

	inline bool isIndependent( void ) const { return m_independent; }

	inline void setIndependent( void ) { m_independent = true; }

private:
	Node* m_next;
	Node* m_prev;
	NodeQueue< Type >* m_queue;
	bool m_independent;
};

}

#endif